package main

import (
	"fmt"
)

func main() {
	a := []int{9, 21, 5, 7, 0, 1, 2, 4, -1}
	quickSort(a, 0, len(a)-1)
	fmt.Println(a)
}

func quickSort(src []int, left, right int) {
	if left >= right {
		return
	}
	num := src[left+(right-left)/2]
	i, j := left, right
	for i <= j {
		if src[i] <= num {
			i++
		} else {
			src[i], src[j] = src[j], src[i]
			j--
		}
	}
	quickSort(src, left, i)
	quickSort(src, i+1, right)
}
